<template>
  <el-header class="layout-header">
    <!-- 图片容器 -->
    <div class="image-container">
      <img
          :src="imageSrc"
          class="header-image"
          :class="{ 'header-image-hover': isHovered }"
          @mouseenter="isHovered = true"
          @mouseleave="isHovered = false"
      >
    </div>

    <!-- 文字标识区域 -->
    <div class="logo-container">
      <div class="brand-wrapper">
        <span class="logo-text">阿里星海</span>
        <span class="version-badge">v1.0.0</span>
      </div>
      <div class="slogan" v-if="showSlogan">数据驱动未来</div>
    </div>
  </el-header>
</template>

<style scoped>
.layout-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid #e8e8e8;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  background-color: #fff;
  transition: box-shadow 0.3s ease;
}

.layout-header:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* 图片容器 */
.image-container {
  display: flex;
  align-items: center;
  margin-right: 20px;
  transition: transform 0.3s ease;
}

.image-container:hover {
  transform: translateY(-2px);
}

/* 图片样式 */
.header-image {
  max-height: 40px;
  max-width: 160px;
  object-fit: contain;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
  padding: 2px;
}

.header-image-hover {
  transform: scale(1.05);
  box-shadow: 0 3px 10px rgba(145, 158, 171, 0.2);
}

/* 品牌标识容器 */
.logo-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-text {
  font-size: 22px;
  font-weight: 600;
  color: var(--el-color-primary);
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
}

.logo-container:hover .logo-text {
  color: var(--el-color-primary-light-3);
}

.version-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
  font-weight: 500;
  transition: all 0.3s ease;
}

.logo-container:hover .version-badge {
  background-color: var(--el-color-primary-light-8);
}

.slogan {
  font-size: 13px;
  color: #606266;
  margin-top: 2px;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
}

.logo-container:hover .slogan {
  color: #303133;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .layout-header {
    padding: 0 16px;
  }

  .image-container {
    margin-right: 12px;
  }

  .logo-text {
    font-size: 18px;
  }

  .slogan {
    display: none;
  }
}
</style>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import mainImage from "@/assets/man.png";

// 图片源
const imageSrc = mainImage;
// 悬停状态
const isHovered = ref(false);
// 是否显示标语
const showSlogan = ref(true);

// 检测屏幕宽度，在小屏幕上隐藏标语
onMounted(() => {
  const checkScreenSize = () => {
    showSlogan.value = window.innerWidth > 768;
  };

  // 初始检查
  checkScreenSize();

  // 监听窗口大小变化
  window.addEventListener('resize', checkScreenSize);

  // 清理函数
  return () => {
    window.removeEventListener('resize', checkScreenSize);
  };
});
</script>
